package src;

import java.util.ArrayList;
import java.util.List;

public class VariationsWithoutRepetition {
	private int[] array;
    private int n;
	private List<List<List<Double>>> allVariations = new ArrayList<List<List<Double>>>();
	private List<List<Double>> fuzzySets = new ArrayList<List<Double>>();
	
    public VariationsWithoutRepetition(List<List<Double>> fuzzySets, int k) {
        this.fuzzySets = fuzzySets;
        this.n = fuzzySets.size();
        array = new int[k];
    }    
    
    private void generate(int fromIndex) {
        if (fromIndex == array.length) {
        	List<List<Double>> variation = new ArrayList<List<Double>>();
        	for (int i = 0; i < array.length; i++) {
//				we generate indexes starting with 1, that's why -1
        		variation.add(fuzzySets.get(array[i] - 1));
			}
        	allVariations.add(variation);
            return;
        }

    	for (int i = 1; i <= n; i++) {
            array[fromIndex] = i;
            generate(fromIndex + 1);                    
        }
    }

    public void generate() {
    	generate(0);
    }
    
    public List<List<List<Double>>> getAllVariations() {
		return allVariations;
	}    
}
